
import { CHANGE_NAME, CHANGE_AGE } from "./constants";
const initialState = {
    name: "gek",
    age: 111,
  };
  // 初始化数据
  // reducer接收两个参数
  // 第一个是当前的state，第二个是action
  const reducer=function reducer(state = initialState, action) {
    switch (action.type) {
      case CHANGE_NAME:
        return {
          ...state,
          name: action.name,
        };
      case CHANGE_AGE:
        return {
          ...state,
          age: action.age,
        };
      default:
        return state;
    }
  }
  module.exports=reducer;